import re

# 匹配字母数字下划线 只匹配开头
# search直到找到为止
search_obj=re.search(r'[0-9]+','1212word test 123',re.I|re.M)
print(search_obj.group())

# match 开始查找，没有则返回None
line = "Cats are smarter than dogs"
matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I)
if matchObj:
   print ("matchObj.group() : ", matchObj.group())
   print ("matchObj.group(1) : ", matchObj.group(1))
   print ("matchObj.group(2) : ", matchObj.group(2))
   print(matchObj.groups())
else:
   print ("No match!!")

# 
find_obj=re.findall(r'[0-9]+','1212word test 123')
print(find_obj)